package edu.gatech.ors.mrsim.applicationtest;

import edu.gatech.ors.mrsim.basictasks.BusyTask;
import edu.gatech.ors.mrsim.basictasks.IdleTask;
import edu.gatech.ors.mrsim.basictasks.ReceiveMessage;
import edu.gatech.ors.mrsim.basictasks.SendMessage;
import edu.gatech.ors.mrsim.basictasks.WaitTask;
import edu.gatech.ors.mrsim.calculate.SimTaskTimer;
import edu.gatech.ors.mrsim.core.SimTask;

public class DefaultTimer implements SimTaskTimer{


	@Override
	public long time(SimTask st) {
	    if (st instanceof WaitTask){
		WaitTask wt = (WaitTask)st;
		return wt.timeToWait;
	    }
	    if (st instanceof IdleTask){
		return ((IdleTask) st).timeToWait;
	    }
	    if (st instanceof BusyTask)
		return ((BusyTask) st).timeToWait;
	    if (st instanceof SendMessage){
		return 0;
	    }
	    if (st instanceof ReceiveMessage){
		return 0;
	    }
	    throw new UnsupportedOperationException();
	}
}
